<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
  <head>
    <title>登录</title>
    <!-- CSS -->
    <script type="text/javascript" src="js/jquery.js"></script>
	<link href="style/bootstrap.css" rel="stylesheet">
	<style type="text/css">
		body{
			padding-top:70px;
			background-image:url(img/kg.png);
		}
		input{
			height: 35px;
		}
		img {
	 		width:200px;
	 		height:50px;
 		}
 		
 		#error{
 			margin-top:70px;
 		}
	</style>
	
	<script type="text/javascript">
		function validateform() {
			
			var username = document.getElementById("username").value;
			var password = document.getElementById("password").value;
			
			if(username.trim().length == 0) {
				document.getElementById("errorforusername").innerHTML = "请输入用户名";
				document.getElementById("username").focus();
				return false;
			} else if(password.length == 0) {
				document.getElementById("errorforpassword").innerHTML = "请输入密码";
				document.getElementById("password").focus();
				return false;
			}
			return true;
		}
		
		function clearError(element){
			document.getElementById(element).innerHTML = "";
		}
	
		function submitForm(){
		
			//validate
			var username = document.getElementById("username").value;
			var password = document.getElementById("password").value;
			
			if(username.trim().length == 0) {
				document.getElementById("errorforusername").innerHTML = "请输入用户名";
				document.getElementById("username").focus();
				return;
			} else if(password.length == 0) {
				document.getElementById("errorforpassword").innerHTML = "请输入密码";
				document.getElementById("password").focus();
				return;
			}
		
			document.getElementById("myform").submit();
		}
	
	</script>
  </head>
  
  <body>
  	  <div class="navbar navbar-fixed-top">
	    <div class="navbar-inner">
		    <div class="container">
	    	    <a class="brand" href="#">
			    	项目管理系统
			    </a>
		    </div>
	    </div>
    </div>
     <form id="myform" action="login.action" method="post" class="well" style="width:220px;margin:0px auto;">
		 <h3>项目管理系统-PMS</h3>
		 <%
	  		String state = request.getParameter("state");
	  		if("10000".equals(state)){
  		%>
  		<div style="color:red" id="error">用户名或密码错误</div>
  		<%}else if("10001".equals(state)){%>
  		<div style="color:green" id="error">密码|昵称修改成功，请重新登录</div>
  		<%} %> 
		 
		  <label>用户名</label>
		  <input type="text" class="span3"name="user.username" id="username" onkeydown="clearError('errorforusername')" onblur="validateform()" autocomplete="off">
		  <span style="color:red" id="errorforusername"></span>
		  <label>密码</label>
		  <input type="password" class="span3" name="user.password" id="password" onkeydown="clearError('errorforpassword')" onblur="validateform()">
		  <span style="color:red" id="errorforpassword"></span>
		  <br/> <br/> 
			
		  <button type="button" class="btn btn-primary" onclick="submitForm()">进入系统《《《《</button>
		</form>
	
  </body>
</html>
